import { createStore } from 'vuex'

export default createStore({
  state: {
    cartList:[], // 购物车的数据
  },
  mutations: {
    addCart(state,val){
      let i = state.cartList.findIndex(item => item.goodId == val.goodId);
      if (i > -1){
        state.cartList[i].number++
        return
      }
      state.cartList.push(val);
    }
  },
  actions: {
  },
  modules: {
  }
})
